#include <cstdlib>

#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iterator>
#include <set>
#include <deque>
#include <array>

#include <boost/lexical_cast.hpp>

template <class ContainerT>
std::vector<long int> container_to_longs(const ContainerT& container)
{
	typedef typename ContainerT::value_type value_type;
	std::vector<long int> ret;
	typedef long int (*func_t)(const value_type&);
	func_t f = &boost::lexical_cast<long int, value_type>;
	std::transform(container.begin(), container.end(), std::back_inserter(ret), f);
	return ret;
}

int main()
{
	std::istringstream iss("100");
	int i;
	iss >> i;

	std::cout << "==== 1 ====" << "    "
		<< std::endl
		<< "i:" << i << "    "
		<< std::endl;

	char* end;
	i = std::strtol("100", &end, 10);
	std::cout << "==== 2 ====" << "    "
		<< std::endl
		<< "i:" << i << "    "
		<< std::endl;

	i = boost::lexical_cast<int>("100");
	std::cout << "==== 3 ====" << "    "
		<< std::endl
		<< "i:" << i << "    "
		<< std::endl;

	char chars[] = { '1', '0', '0' };
	i = boost::lexical_cast<int>(chars, 3);
	std::cout << "==== 4 ====" << "    "
		<< std::endl
		<< "i:" << i << "    "
		<< std::endl;

	std::string s = "100";
	i = boost::lexical_cast<int>(s);
	std::cout << "==== 5 ====" << "    "
		<< std::endl
		<< "i:" << i << "    "
		<< std::endl;

	std::set<std::string> str_set;
	str_set.insert("1");
	std::cout << "==== 6 ====" << "    "
		<< std::endl
		<< "container_to_longs(str_set).front():" << container_to_longs(str_set).front() << "    "
		<< std::endl;

	std::deque<const char*> char_deque;
	char_deque.push_front("1");
	char_deque.push_back("2");
	std::cout << "==== 7 ====" << "    "
		<< std::endl
		<< "container_to_longs(char_deque).front():" << container_to_longs(char_deque).front() << "    "
		<< "container_to_longs(char_deque).back():" << container_to_longs(char_deque).back() << "    "
		<< std::endl;

	typedef std::array<unsigned char, 2> element_t;
	std::array<element_t, 2> arrays = { { {{'1', '0'}}, {{'2', '0'}} } };
	std::cout << "==== 8 ====" << "    "
		<< std::endl
		<< "container_to_longs(arrays).front():" << container_to_longs(arrays).front() << "    "
		<< "container_to_longs(arrays).back():" << container_to_longs(arrays).back() << "    "
		<< std::endl;

	return 0;
}